package com.carrie.mdg.myviewtext.activity;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.TextureView;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;

import com.carrie.mdg.myviewtext.R;

import androidLib.activity.BaseActivity;

public class LoginActivity extends BaseActivity {
    private EditText username;
    private EditText etPassword;
    private Button login;
    private CheckBox rememberPass;

    private String account, password;

    public static void actionStart(Context context) {
        Intent intent = new Intent(context, LoginActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void initVariables() {

    }

    @Override
    protected void initViews(Bundle savedInstanceState) {
        setContentView(R.layout.activity_login);
        username = (EditText) findViewById(R.id.editText_name);
        etPassword = (EditText) findViewById(R.id.editText_password);
        login = (Button) findViewById(R.id.button_login);
        rememberPass = (CheckBox) findViewById(R.id.checkBox);
    }

    @Override
    protected void initEvent() {
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                account = username.getText().toString().trim();
                password = etPassword.getText().toString().trim();
                if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(password) &&
                        account.equals("admin") && password.equals("123456")) {
                    LoginTextMainActivity.actionStart(LoginActivity.this);
                } else {
                    Toast.makeText(LoginActivity.this, "account or password is invalid", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

    @Override
    protected void loadData() {

    }
}
